<include file="Index:header" />
<!-- Content Header (Page header) -->
    <section class="content-header">
      <h1> 更新栏目 </h1>
      <ol class="breadcrumb">
        <li><a href="__APP__/TIFAWEB_DSWJCMS.html" class="goindex"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li> 文章管理</li>
        <li><a href="__APP__/TIFAWEB_DSWJCMS/Site.html"> 栏目管理</a></li>
        <li class="active">更新栏目</li>
      </ol>
    </section>
<!--主体-->
    <!-- Main content -->
  <section class="content">
  <form method="post"  action='__APP__/TIFAWEB_DSWJCMS/Site/tfUpdasite' enctype="multipart/form-data">
  <input name="sid" type="hidden" value="{$list['id']}" />
 <input name="user_id" type="hidden" value="{$list['user_id']}" />
  <input name="catpid" id="catpid" type="hidden" value="{$list['catpid']}" />
  <input name="u"  type="hidden" value="__APP__/TIFAWEB_DSWJCMS/Site.html" />
   <input name="aid" id="aid" type="hidden" value="{$list['aid']}" />
    <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#basic" data-toggle="tab">基本信息</a></li>
              <li><a href="#detailed" data-toggle="tab">详细信息</a></li>
            </ul>
            <div class="tab-content">
              <div class="active tab-pane" id="basic">
              <!--基本信息 --> 
              <table class="table">
              <tbody>
                  <tr>
                    <td>
                           栏目名称：
                    </td>
                    <td>
                      <input name="title" type="text" class="form-control" placeholder="请输入分类名称..." maxlength="30" value="{$list.title}">
                    </td>
                  </tr>
                  <tr>
                    <td>
                           自定义链接：
                    </td>
                    <td>
                      <input name="link" type="text" class="form-control" placeholder="请输入自定义链接..." maxlength="100" value="{$list.link}">
                    </td>
                  </tr>
                  <tr>
                    <td>
                           上级类目：
                    </td>
                    <td>
                    <if condition="$site">
                  <select name="pid" id="pid" class="form-control"  onchange="var id=$(this).val();orclick(id);setCatPid(id);">
                  <option value="{$list.pid}" class="cal{$sites.order}">{$sites.title}</option>
                  <option value="0" id="Type">顶级类目</option>
                  <volist id="vo" name="site">
                  <option id="o_{$vo.id}" value="{$vo.id}" class="cal{$vo.order}" catpid="{$vo.absPath}" order="{$vo.order}">
                    <if condition="intval($vo['order']) eq 1 ">
                       {$vo.title}
                  
                   <elseif condition="intval($vo['order']) eq 2 " />
                    ├ {$vo.title}
                    <elseif condition="intval($vo['order']) eq 3 " /> 
                    │├ {$vo.title}
                    <elseif condition="intval($vo['order']) eq 4 " /> 
                   ││├ {$vo.title}
                    <elseif condition="intval($vo['order']) eq 5 " /> 
                    │││├ {$vo.title}
                    <else />
                    │--├ {$vo.title}
                    </if>

                  </option>
                  </volist>
                  </select>
                  </if>
                    </td>
                  </tr>
                   <tr>
                    <td>
                           关键字：
                    </td>
                    <td>
                      <input name="keyword" type="text" class="form-control" placeholder="请输入关键字..." maxlength="100" value="{$list.keyword}">
                    </td>
                  </tr>
          <tr>
                    <td>
                           描述：
                    </td>
                    <td>
                      <textarea name="remark" class="form-control" placeholder="请输入描述..." maxlength="200" style="height:200px;">{$list.remark}</textarea>
                    </td>
                  </tr>

                  <tr>
                    <td>
                           页面类型：
                    </td>
                    <td class="form-group">
                    
                      
                      <if condition="intval($list['type']) eq 1">
                      <label><input class="minimal" type="radio" name="type" value="1" checked /> 封面</label>
                      <label ><input class="minimal" type="radio" name="type" value="2"/> 列表</label>
                      <label ><input class="minimal" type="radio" name="type" value="3"/> 内容</label>
                     <elseif condition="intval($list['type']) eq 2" />
                     <label><input class="minimal" type="radio" name="type" value="1"  /> 封面</label>
                      <label ><input class="minimal" type="radio" name="type" value="2" checked/> 列表</label>
                      <label ><input class="minimal" type="radio" name="type" value="3"/> 内容</label>
                      <else />
                      <label><input class="minimal" type="radio" name="type" value="1"  /> 封面</label>
                      <label ><input class="minimal" type="radio" name="type" value="2"/> 列表</label>
                      <label ><input class="minimal" type="radio" name="type" value="3" checked/> 内容</label>                         
                      </if>
                      
                      
                      
                    </td>
                  </tr>
                   <tr>
                    <td>
                           列表模板：
                    </td>
                    <td class="form-inline">
                          <input name="list_tpl" type="text" class="form-control" value="{$list.list_tpl}">
                    </td>
                  </tr> 
                   <tr>
                    <td>
                           内容页模板：
                    </td>
                    <td class="form-inline">
                          <input name="content_tpl"  id="content_tpl" type="text" class="form-control" value="{$list.content_tpl}">
                    </td>
                  </tr>                                                                                                               
                  
                  <tr>
                    <td>
                           显示/隐藏：
                    </td>
                    <td class="form-group">
                       <if condition="intval($list['status']) eq 1">
                      <label ><input class="minimal" type="radio" name="status" value="1"  checked /> 显示</label>
                      <label><input class="minimal" type="radio" name="status" value="0"/> 隐藏</label>
                      <else />
                      <label ><input class="minimal" type="radio" name="status" value="1"   /> 显示</label>
                      <label><input class="minimal" type="radio" name="status" value="0" checked/> 隐藏</label>
                      </if>
                    </td>
                  </tr>
                  <tr>
                    <td>
                           排序：
                    </td>
                    <td>
                     <input name="orde" type="text" class="form-control"  value="{$list.orde}">
                    </td>
                  </tr>
                </tbody>
               </table>
              <!--基本信息 end--> 
              </div>
              <div class="tab-pane" id="detailed">
              <!--详细信息 --> 
              <table class="table">
               <tbody>
                <tr>
                  <td>
                         缩略图：
                  </td>
                  <td>
                  <if condition="$list.litpic neq ''">
                  	<div class="imgupload"  id="fileList"  style="width:202px;height:102px;">
                    <input name="litpic" type="hidden" value="{$list.litpic}" />
                    <img src="__PUBLIC__/uploadify/uploads/site/{$list.litpic}" style="width:200px;height:100px;"/>
                    </div>
                  <else/>
                  	<div class="imgupload"  id="fileList"  style="width:202px;height:102px;">
                    <span class="fa fa-plus"></span>
                    </div>
                  </if>
                    <input name="input" type="file" id="fileElem" multiple accept="image/*"  onchange="handleFiles(this)" class="hide">	
                  
                  </td>
                </tr>  
                <tr>
                  <td>
                         调用模型：
                  </td>
                  <td>
                       <input name="model" type="text" class="form-control" value="{$list.model}">
                  </td>
                </tr>                    
               
                <tr>
                  <td>
                         内容：
                  </td>
                  <td>
                      <textarea class="editor" name="content" style="width:100%;height:400px;">{$list.content}</textarea>  
                  </td>
                </tr>
                 <input id="order" name="order" type="hidden" class="span2"  value="{$list.order}">
                                  
                </tbody>
                </table>
              <!--详细信息 end--> 
              </div>
             
            </div>
            <!-- /.tab-content -->
          </div>
          <!-- /.nav-tabs-custom -->
    <div class="row">
     <button class="btn btn-primary pull-right" style="margin-right: 15px;"  type="submit">
                  提交
              </button>
    </div>
    </form>
    
  </section>
<include file="Index:footer" />

<script>
//页面类型
$(function(){
	$("input:radio[name='type']").on('ifChecked', function(event){
		var i=$(this).val();
	  if(i==3){
		 $('#content_tpl').val('page');
	  }else{
	  	 $('#content_tpl').val('content');
	  }
	 
	  
	});
}); 
//上级类目处理
function setCatPid(v){
		 if(v==0){
			catpid=0;	
		}else{
			 var catpid  = $("#o_"+v).attr("catpid");
		}
		 $("#catpid").attr("value",catpid);
	 }
	 function orclick(s){
		if(s==0){
			order=1;	
		}else{
			var order =  $("#o_"+s).attr("order");
			order=parseInt(order)+1;
		}
		$('#order').val(order);	
	}
//图片上传处理
window.URL = window.URL || window.webkitURL;
    var fileElem = document.getElementById("fileElem"),
    fileList = document.getElementById("fileList");
	fileList.addEventListener('click',function(){
		fileElem.click();
	},false);
    function handleFiles(obj) {
        var files = obj.files,
        img = new Image();
        if(window.URL){
            //File API
            //alert(files[0].name + "," + files[0].size + " bytes");
            img.src = window.URL.createObjectURL(files[0]); //创建一个object URL，并不是你的本地路径
            img.onload = function(e) {
                window.URL.revokeObjectURL(this.src); //图片加载后，释放object URL
            }
			
            fileList.innerHTML='<img src="'+img.src+'" style="width:200px;height:100px;"/>';
        }else if(window.FileReader){
            //opera不支持createObjectURL/revokeObjectURL方法。我们用FileReader对象来处理
            var reader = new FileReader();
            reader.readAsDataURL(files[0]);
            reader.onload = function(e){
               // alert(files[0].name + "," +e.total + " bytes");
                img.src = this.result;
                img.width = 200;
                 fileList.innerHTML='<img src="'+img.src+'"  style="width:200px;height:100px;"/>';
            }
        }else{
            //ie
            obj.select();
            obj.blur();
            var nfile = document.selection.createRange().text;
            document.selection.empty();
            img.src = nfile;
            img.width = 200;
            img.onload=function(){
                //alert(nfile+","+img.fileSize + " bytes");
            }
            fileList.innerHTML='<img src="'+img.src+'"  style="width:200px;height:100px;"/>';
        }
    }
	
</script>
<!-- editor -->
<script src="__PUBLIC__/editor/kindeditor-min.js"></script>
<script>
	var editor;
	KindEditor.ready(function(K) {
			editor = K.create('.editor');
	});
</script>